package demo07;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class Person {
    private String name;

    public Person() {
        System.out.println("Person()的构造器被调用了-----1");
    }

    public String getName() {
        return name;
    }

    @Value("张三")
    public void setName(String name) {
        System.out.println("name的set方法被调用了------2");
        this.name = name;
    }

    public void play() {
        System.out.println("出去玩爽pwq ----" + name);

    }

    @PostConstruct
    public void init() {
        System.out.println("Spring容器将Person对象初始化完毕了，init方法被调用了----3");
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("容器要关闭了，通知当前对象 -------5");

    }
}